package com.bw.zonghe0719.adapter

import android.graphics.Color
import android.widget.LinearLayout
import android.widget.TextView
import com.bw.base.entity.ExplosiveMoney
import com.bw.zonghe0719.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class TypeAdapter:BaseQuickAdapter<ExplosiveMoney,BaseViewHolder>(R.layout.item_type) {
    var selectedType=4//设置默认选中第一个 有背景色
    override fun convert(holder: BaseViewHolder, item: ExplosiveMoney) {
        holder.getView<TextView>(R.id.type_info).text=item.info
        holder.getView<TextView>(R.id.type_name).text=item.name
        if(item.type.toInt()==selectedType){
            holder.getView<LinearLayout>(R.id.ll_type).setBackgroundResource(R.drawable.bg_selected)
        }else{
            holder.getView<LinearLayout>(R.id.ll_type).background=null
        }
    }
    fun setType(type:Int){
        selectedType=type
        notifyDataSetChanged()
    }
}